package com.api.utils;

import java.util.List;


/**
 * Created by PC on 2017/7/10.
 */
public class RollPage<T> {
    List<T> recordList;//记录列表

    Integer iTotalRecords;//记录总数


    Integer iTotalDisplayRecords;//显示记录总数

    Integer pageSize;//分页参数

    Integer pageNum;//当前页数

    public List<T> getRecordList() {
        return recordList;
    }

    public Integer getiTotalRecords() {
        return iTotalRecords;
    }

    public Integer getiTotalDisplayRecords() {
        return iTotalDisplayRecords;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public Integer getPageSum() {
        return (int) Math.ceil((this.iTotalRecords)*1.0 / this.pageSize); //+ ((this.iTotalRecords % this.pageSize==0)?0:1)
    }

    public RollPage(Integer recordSum, Integer pageNum) {
        Integer pageSizeCustom = 10;
        iTotalRecords = recordSum;
        iTotalDisplayRecords = recordSum;
        pageSize = pageSizeCustom;
        this.pageNum = pageNum != null ? pageNum : 1;
    }

    public RollPage(Integer recordSum, Integer pageNum, Integer pageSize) {

        iTotalRecords = recordSum;
        iTotalDisplayRecords = recordSum;
        this.pageNum = pageNum != null ? pageNum : 1;
        this.pageSize = pageSize;
    }

    public Integer getPageOffset() {
        return (pageNum - 1) * pageSize;
    }
    public void setRecordList(List<T> recordList) {
        this.recordList = recordList;
    }

}
